import Vue from 'vue'
import VueRouter from 'vue-router';
Vue.use(VueRouter)
// 创建路由规则
const routes = [{
    path:'/',
    name:'index',
    component:() => import("@/views/index")
},{
    path:'/login',
    name:'login',
    component:() => import("@/views/login/MyLogin.vue")
}];
// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
let routerReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push(location) {
    return routerReplace.call(this, location).catch(err => err)
}

export default new VueRouter({
    mode: 'history', // 去掉url中的#
    scrollBehavior: () => ({ y: 0 }),
    routes: routes
})
